<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>cat APIs | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'cat.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cat.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cat.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/cat.html" rel="nofollow" target="_blank">../en/cat.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-node">cat APIs</span>
</div>
<div class="navheader">
<span class="prev">
<a href="url-access-control.html">« URL-based access control</a>
</span>
<span class="next">
<a href="cat-alias.html">cat aliases API »</a>
</span>
</div>
<div class="chapter">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="cat"></a>cat APIs<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h2>
</div></div></div>
<h3>
<a id="intro"></a>Introduction<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h3>
<p>JSON is great…​ for computers. Even if it’s pretty-printed, trying
to find relationships in the data is tedious. Human eyes, especially
when looking at a terminal, need compact and aligned text. The cat APIs
aim to meet this need.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>cat APIs are only intended for human consumption using the
<a href="https://www.elastic.co/guide/en/kibana/7.7/console-kibana.html" class="ulink" target="_top">Kibana console</a> or command line. They are <em>not</em>
intended for use by applications. For application consumption, we recommend
using a corresponding JSON API.</p>
</div>
</div>
<p>All the cat commands accept a query string parameter <code class="literal">help</code> to see all
the headers and info they provide, and the <code class="literal">/_cat</code> command alone lists all
the available commands.</p>
<h3>
<a id="common-parameters"></a>Common parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h3>
<h4>
<a id="verbose"></a>Verbose<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h4>
<p>Each of the commands accepts a query string parameter <code class="literal">v</code> to turn on
verbose output. For example:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_cat/master?v</pre>
</div>
<div class="console_widget" data-snippet="snippets/1343.console"></div>
<p>Might respond with:</p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">id                     host      ip        node
u_n93zwxThWHi1PDBJAGAg 127.0.0.1 127.0.0.1 u_n93zw</pre>
</div>
<h4>
<a id="help"></a>Help<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h4>
<p>Each of the commands accepts a query string parameter <code class="literal">help</code> which will
output its available columns. For example:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_cat/master?help</pre>
</div>
<div class="console_widget" data-snippet="snippets/1344.console"></div>
<p>Might respond with:</p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">id   |   | node id
host | h | host name
ip   |   | ip address
node | n | node name</pre>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p><code class="literal">help</code> is not supported if any optional url parameter is used.
For example <code class="literal">GET _cat/shards/twitter?help</code> or <code class="literal">GET _cat/indices/twi*?help</code>
results in an error. Use <code class="literal">GET _cat/shards?help</code> or <code class="literal">GET _cat/indices?help</code>
instead.</p>
</div>
</div>
<h4>
<a id="headers"></a>Headers<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h4>
<p>Each of the commands accepts a query string parameter <code class="literal">h</code> which forces
only those columns to appear. For example:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_cat/nodes?h=ip,port,heapPercent,name</pre>
</div>
<div class="console_widget" data-snippet="snippets/1345.console"></div>
<p>Responds with:</p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">127.0.0.1 9300 27 sLBaIGK</pre>
</div>
<p>You can also request multiple columns using simple wildcards like
<code class="literal">/_cat/thread_pool?h=ip,queue*</code> to get all headers (or aliases) starting
with <code class="literal">queue</code>.</p>
<h4>
<a id="numeric-formats"></a>Numeric formats<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h4>
<p>Many commands provide a few types of numeric output, either a byte, size
or a time value.  By default, these types are human-formatted,
for example, <code class="literal">3.5mb</code> instead of <code class="literal">3763212</code>.  The human values are not
sortable numerically, so in order to operate on these values where
order is important, you can change it.</p>
<p>Say you want to find the largest index in your cluster (storage used
by all the shards, not number of documents).  The <code class="literal">/_cat/indices</code> API
is ideal.  You only need to add three things to the API request:</p>
<div class="olist orderedlist">
<ol class="orderedlist">
<li class="listitem">
The <code class="literal">bytes</code> query string parameter with a value of <code class="literal">b</code> to get byte-level resolution.
</li>
<li class="listitem">
The <code class="literal">s</code> (sort) parameter with a value of <code class="literal">store.size:desc</code> to sort the output
by shard storage in descending order.
</li>
<li class="listitem">
The <code class="literal">v</code> (verbose) parameter to include column headings in the response.
</li>
</ol>
</div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_cat/indices?bytes=b&amp;s=store.size:desc&amp;v</pre>
</div>
<div class="console_widget" data-snippet="snippets/1346.console"></div>
<p>The API returns the following response:</p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">health status index    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   twitter  u8FNjxh8Rfy_awN11oDKYQ   1   1       1200            0      72171         72171
green  open   twitter2 nYFWZEO7TUiOjLQXBaYJpA   1   0          0            0        230          230</pre>
</div>
<p>If you want to change the <a class="xref" href="common-options.html#time-units" title="Time units">time units</a>, use <code class="literal">time</code> parameter.</p>
<p>If you want to change the <a class="xref" href="common-options.html#size-units" title="Unit-less quantities">size units</a>, use <code class="literal">size</code> parameter.</p>
<p>If you want to change the <a class="xref" href="common-options.html#byte-units" title="Byte size units">byte units</a>, use <code class="literal">bytes</code> parameter.</p>
<h4>
<a id="_response_as_text_json_smile_yaml_or_cbor"></a>Response as text, json, smile, yaml or cbor<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h4>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">% curl 'localhost:9200/_cat/indices?format=json&amp;pretty'
[
  {
    "pri.store.size": "650b",
    "health": "yellow",
    "status": "open",
    "index": "twitter",
    "pri": "5",
    "rep": "1",
    "docs.count": "0",
    "docs.deleted": "0",
    "store.size": "650b"
  }
]</pre>
</div>
<p>Currently supported formats (for the <code class="literal">?format=</code> parameter):
- text (default)
- json
- smile
- yaml
- cbor</p>
<p>Alternatively you can set the "Accept" HTTP header to the appropriate media format.
All formats above are supported, the GET parameter takes precedence over the header.
For example:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">% curl '192.168.56.10:9200/_cat/indices?pretty' -H "Accept: application/json"
[
  {
    "pri.store.size": "650b",
    "health": "yellow",
    "status": "open",
    "index": "twitter",
    "pri": "5",
    "rep": "1",
    "docs.count": "0",
    "docs.deleted": "0",
    "store.size": "650b"
  }
]</pre>
</div>
<h4>
<a id="sort"></a>Sort<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/cat.asciidoc">edit</a>
</h4>
<p>Each of the commands accepts a query string parameter <code class="literal">s</code> which sorts the table by
the columns specified as the parameter value. Columns are specified either by name or by
alias, and are provided as a comma separated string. By default, sorting is done in
ascending fashion. Appending <code class="literal">:desc</code> to a column will invert the ordering for
that column. <code class="literal">:asc</code> is also accepted but exhibits the same behavior as the default sort order.</p>
<p>For example, with a sort string <code class="literal">s=column1,column2:desc,column3</code>, the table will be
sorted in ascending order by column1, in descending order by column2, and in ascending
order by column3.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _cat/templates?v&amp;s=order:desc,index_patterns</pre>
</div>
<div class="console_widget" data-snippet="snippets/1347.console"></div>
<p>returns:</p>
<div class="pre_wrapper lang-txt">
<pre class="programlisting prettyprint lang-txt">name                  index_patterns order version
pizza_pepperoni       [*pepperoni*]  2
sushi_california_roll [*avocado*]    1     1
pizza_hawaiian        [*pineapples*] 1</pre>
</div>
























</div>
<div class="navfooter">
<span class="prev">
<a href="url-access-control.html">« URL-based access control</a>
</span>
<span class="next">
<a href="cat-alias.html">cat aliases API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>